/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package action.organization;

import com.opensymphony.xwork2.ActionSupport;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import myUtils.page.Result;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;
import service.OrgService;

/**
 *
 * @author luyang
 */
public class MemberListAction extends ActionSupport implements ServletRequestAware,SessionAware
{
    private HttpServletRequest request;
    private OrgService orgService;
    private Map session;

     @Override
    public String execute()
     {
         int page=request.getParameter("page")==null?1:Integer.parseInt((String) request.getParameter("page"));
         int id;
         String msg;
         if(request.getParameter("id")==null)
         {
             msg="no id!!!";
             request.setAttribute("msg", msg);
             return ERROR;
         }

         id=Integer.parseInt(request.getParameter("id"));
         Result checked=orgService.getCheckedMembers(id, page);
         Result unchecked=orgService.getUncheckedMembers(id, page);
         request.setAttribute("checked", checked);
         request.setAttribute("unchecked", unchecked);
         request.setAttribute("id", String.valueOf(id));

         return SUCCESS;
     }

    public void setOrgService(OrgService orgService)
    {
        this.orgService=orgService;
    }

    public void setServletRequest(HttpServletRequest request)
    {
        this.request=request;
    }

    public void setSession(Map session)
    {
        this.session=session;
    }

}
